<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   	xmlns:h="http://java.sun.com/jsf/html"
   	xmlns:ui="http://java.sun.com/jsf/facelets"
   	xmlns:c="http://java.sun.com/jsp/jstl/core"
   	xmlns:f="http://java.sun.com/jsf/core"
   	xmlns:rich="http://richfaces.org/rich"
   	xmlns:a4j="http://richfaces.org/a4j"
   	xmlns:t="http://myfaces.apache.org/tomahawk"
   	xmlns:bargas="http://barganhas.com.br/barganhas">
   	
   	<f:view contentType="text/html">
   		<f:loadBundle var="msg" basename="messages"/>
   		<h:head>
   			<title>
   				<ui:insert name="baseTitle">
   					<h:outputText value="#{msg.appTitle}"/>
   				</ui:insert>
   			</title>
   			<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
			<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/styles-site.css" />
			<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/styles-messages.css" />
			<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/styles-richfaces.css" />
			<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/styles-shared.css" />
   			<script type="text/javascript" src="#{request.contextPath}/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.2.2.Final/Packed/jquery.js"></script>
   			<script src="#{request.contextPath}/javascript/module.js" type="text/javascript" />
   			<script src="#{request.contextPath}/javascript/jquery.maskMoney.js" type="text/javascript" />
   		</h:head>
   		
   		<h:body>
   			<bargas:loading />
   			<bargas:messages />
			<bargas:jsFunction />
			
			<c:if test="#{appSessionBean.userAccount eq null}">
				<ui:decorate template="/xhtml/account/accountNewPopup.xhtml"/>
			</c:if>
   			
   			<h:panelGroup id="bodySite" layout="block">
				<h:panelGroup id="site" layout="block">
   					<h:form id="formTop" prependId="false">
		   				<h:panelGroup id="top" layout="block">
		   					<h:panelGroup id="topLinks" layout="block">
								<ul>
									<c:if test="#{appSessionBean.userAccount ne null}">
										<li>
											<h:outputText styleClass="welcomeMsg" value="#{msg.loginWelcomeMsg} "/>
											<h:outputText styleClass="welcomeMsg" value="#{appSessionBean.userAccount.nickname}"/>
										</li>
									</c:if>
									<li>
										<h:commandLink action="#{siteBean.goToIndex}" value="#{msg.appStart}" />
									</li>
									<c:if test="#{appSessionBean.userAccount eq null}">
										<li>
											<h:commandLink action="#{userAccountBean.goToLogin}" value="#{msg.enterMsg}" />
										</li>
									</c:if>
									<li>
										<h:commandLink action="#{userAccountBean.consult}" value="#{msg.myRegister}"/>
									</li>
									<c:choose>
										<c:when test="#{appSessionBean.userAccount eq null}">
											<li>
												<a4j:commandLink actionListener="#{userAccountBean.prepareRegister}"
													immediate="true"
													value="#{msg.registerYourSelf}"
													render="accountNewPopupForm"
													onclick="popupLoading(true);" oncomplete="popupLoading(false);"/>
											</li>
										</c:when>
										<c:otherwise>
											<li>
												<h:commandLink action="#{advertisementBean.prepareNewStepOne}" value="#{msg.advertisementNewAdvertisement}" />
											</li>
										</c:otherwise>
									</c:choose>
									<li >
										<h:commandLink value="#{msg.contact}" action="#{siteContactBean.goToSiteContact}"/>
									</li>
									<c:if test="#{appSessionBean.userAccount ne null}">
										<li>
											<h:commandLink action="#{userAccountBean.logoff}" value="#{msg.logoffCamelCaseMsg}"/>
										</li>
									</c:if>
								</ul>
							</h:panelGroup>
							
							<h:panelGrid columns="2" columnClasses="columnLogo, columnSearchForm" styleClass="tableTopSearch">
								<h:column>
									<a href="#{request.contextPath}/" id="logo" >
										<h:graphicImage value="/images/logo/logo2-3.png" width="350px"/>
									</a>
								</h:column>
								
								<h:column>
									<h:panelGroup layout="block" id="searchform">
										<h:inputText id="searchField" value="#{siteBean.searchText}"/>
										<h:commandButton value="#{msg.buttonFind}" styleClass="customButton" action="#{siteBean.search}" immediate="false" 
											onclick="return validateInputSearch();"/>
									</h:panelGroup>
								</h:column>
							</h:panelGrid>
						</h:panelGroup>
   					</h:form>
					
					<h:form prependId="false" id="formNavigation">
						<ui:insert name="bodyNavigation"/>
					</h:form>
					
					<h:form id="formFooter" prependId="false">
						<h:panelGroup id="footer" layout="block">
								<ul>
									<li><h:commandLink value="#{msg.aboutTheSite}" action="#{aboutSiteBean.aboutSite}"/></li>
									<li><h:commandLink value="#{msg.termsOfTheSite}" action="#{useTermBean.useTerm}"></h:commandLink></li>
									<li style="border: 0px;">
										<h:commandLink value="#{msg.contact}" action="#{siteContactBean.goToSiteContact}"/>
									</li>
<!-- 									<li><a href="#">#{msg.mapOfTheSite}</a></li> -->
								</ul>
								
								<p>#{msg.copyRightMsg}</p>
						</h:panelGroup>
					</h:form>
					
					<h:outputScript>
						function validateInputSearch() {
							if (lessThan($j("#searchField").val().length, 1)) {
								alert("Indique um texto para busca!");
								$j("#searchField").focus();
								return false;
							}
							return true;
						}
					</h:outputScript>
				</h:panelGroup>
   			</h:panelGroup>
   		</h:body>
   	</f:view>
</html>